﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace GameWP
{
    public class Arrow : Sprite2D
    {
    #region Properties
        protected float _speed;
        public float Speed
        {
            get { return _speed; }
            set { _speed = value; }
        }

        public float PositionX
        {
            set { _position.X = value; }
        }

        protected SpriteEffects _spriteEffect;
        public SpriteEffects SpriteEffect
        {
            get { return _spriteEffect; }
            set { _spriteEffect = value; }
        }

        protected float _scaleTexture;
        public float ScaleTexture
        {
            get { return _scaleTexture; }
            set { _scaleTexture = value; }
        }
    #endregion

    #region Initiation
        public Arrow(Texture2D texture, Vector2 posotion, float speed, SpriteEffects spriteEffect, float  scaleTuexture)
            :base(texture, posotion)            
        {
            _position = posotion;
            _texture = texture;
            _speed = speed;
            _spriteEffect = spriteEffect;
            _scaleTexture = scaleTuexture;
            if (_texture != null)
            {
                _rectangle = new Rectangle
                ((int)_position.X, (int)_position.Y, _texture.Width, _texture.Height);
            }
            _scaleRect = -10;
        }
    #endregion    

    #region Update
        public override void Update(GameTime gametime, Vector2 position)
        {
            _position.X -= 10 * _speed;
            _rectangle.X = (int)_position.X;
        }

        public override void Draw(SpriteBatch spritebatch, GameTime gametime)
        {
            spritebatch.Draw(_texture, _position, null, Color.White, 0, Vector2.Zero, _scaleTexture, _spriteEffect, 0);
        }
    #endregion
    }
}
